package com.power;

import com.plf.core.config.SaTokenConfigure;
import com.plf.core.login.LoginController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;

@ComponentScan(basePackages = {"com.power", "com.plf", "com.ding", "com.remote"}, excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {LoginController.class, SaTokenConfigure.class})})
@EnableJpaRepositories(basePackages = {"com.plf.core", "com.power"})
@EntityScan(basePackages = {"com.plf.core", "com.power.sifa"})
@SpringBootApplication(scanBasePackages = {"com.plf", "com.account", "com.power.sifa"}, exclude = {RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class, MongoAutoConfiguration.class, MongoReactiveAutoConfiguration.class})
@EnableFeignClients(basePackages = {"com.power", "com.account", "com.power.sifa", "com.ding","com.remote"})
@EnableScheduling
@EnableDiscoveryClient
public class SfapproveApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SfapproveApplication.class, args);
        Environment environment = context.getBean(Environment.class);

        String port = environment.getProperty("server.port");
        String path = environment.getProperty("server.servlet.context-path");
        String nacosUrl = environment.getProperty("spring.cloud.nacos.discovery.server-addr");
        String nameSpace = environment.getProperty("spring.cloud.nacos.discovery.namespace");

        System.out.println(String.format("\n------ 司法审批端启动成功 http://localhost:%s%s/ ------------", port, path));
        System.out.println(String.format("\n------- nacos地址:%S，命名空间:%s ------------", nacosUrl, nameSpace));
    }
}
